<template>
    <el-dialog title="修改设备" width="50%" :visible.sync="showHide" :show-close="false" :close-on-click-modal="false">
        <el-form :model="params">
            <el-form-item label="设备名称" :label-width="formLabelWidth">
                <el-input v-model="params.detail" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="设备编号" :label-width="formLabelWidth">
                <el-input v-model="params.equipmentNo" autocomplete="off" :disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="序列号" :label-width="formLabelWidth">
                <el-input v-model="params.imei" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="类别" :label-width="formLabelWidth">
                <el-select v-model="params.type" placeholder="选择使用类型">
                    <el-option label="家用" value="1"></el-option>
                    <el-option label="商用" value="2"></el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="devClose1">取 消</el-button>
            <el-button type="primary" @click="devClose">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
import { ModifyDevice } from '@/api/table'
import { Message } from 'element-ui'
export default {
    data() {
        return {
            formLabelWidth: '120px',
        };
    },
    props: {
        params: {
            type: Object,
            required: true
        },
        // 显示隐藏
        showHide: {
            type: Boolean,
            required: true
        },
    },
    methods: {
        handleClose(done) {
            this.$confirm('确认关闭？')
                .then(_ => {
                    done();
                })
                .catch(_ => { });
        },
        devClose1() {
            this.$emit('custom-event', false);
        },
        devClose() {
            this.$emit('custom-event', false);
            let devData = JSON.stringify(this.params)
            let data = { params: devData }
            ModifyDevice(data).then(res => {
                Message({
                    message: res.msg,
                    type: 'success',
                    duration: 3 * 1000
                })
            })
        }
    }
};
</script>